package com.hbjycl.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.hbjycl.entity.Admin;
import com.hbjycl.service.AdminService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import java.util.List;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController extends BaseController
{
    
    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
    @Resource
    private AdminService        adminService;
    
    /**
     * 前台首页
     * 
     * @param session
     * @return
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public ModelAndView index(HttpSession session, HttpServletRequest request)
    {  
    	ModelAndView mav = new ModelAndView();
    	if(session!=null)
    	{
            mav.addObject("username", session.getAttribute("username"));
    	}    
        mav.setViewName("index");
        return mav;
    }
	   /*
     * 退出登录
     */
	   @RequestMapping(value = "logout", method = RequestMethod.GET)
	    public ModelAndView logout(HttpSession httpsession, HttpServletRequest request)	    		
	    {
	        ModelAndView mav = new ModelAndView();
	        mav.setViewName("index");
	        httpsession.removeValue("username");
	        return mav;
	    }
    
}